package dyyx.util;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public abstract class ConfigUtil {

	private static final String CONFIG = "config.properties";
	
	
    private static  Properties config = null;
    
    static{
    	Properties prop = CommUtil.readProperties(CONFIG);
    	config = prop;
    }
    
    
    public static String get(String key){
    	if(CommUtil.isBlank(key)){
    		return null;
    	}
    	String value = config.getProperty(key);
    	if(value!=null){
    		value = value.trim();
    	}
    	return value;
    }
    
    public static int getInt(String key){
    	if(CommUtil.isBlank(key)){
    		return 0;
    	}
    	
    	return CommUtil.getInt(get(key));
    }
    
    public static long getLong(String key){
    	if(CommUtil.isBlank(key)){
    		return 0;
    	}
    	
    	return CommUtil.getLong(get(key));
    }
    
   
    public static Map<String,String> getAllConfig(){
    	Map<String,String> map = new HashMap(config);
    	return map;
    }

}